package com.lutzyt.delivery.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lutzyt.delivery.bean.HorsemanAccountFlow;
import com.lutzyt.delivery.mapper.HorsemanAccountFlowDAO;
import com.lutzyt.delivery.service.HorsemanAccountFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zyt
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class HorsemanAccountFlowServiceImpl extends ServiceImpl<HorsemanAccountFlowDAO, HorsemanAccountFlow> implements HorsemanAccountFlowService {

  private HorsemanAccountFlowDAO horsemanAccountFlowDAO;

  @Transactional(readOnly = true)
  @Override
  public HorsemanAccountFlow findById(Integer id) {
    return horsemanAccountFlowDAO.selectById(id);
  }

  @Transactional(readOnly = true)
  @Override
  public IPage<HorsemanAccountFlow> findByPage(int pageNum, int pageSize) {
    return horsemanAccountFlowDAO.selectPage(new Page<>(pageNum, pageSize), null);
  }

  @Override
  public void insert(HorsemanAccountFlow horsemanAccountFlow) {
    horsemanAccountFlowDAO.insert(horsemanAccountFlow);
  }

  @Override
  public void update(HorsemanAccountFlow horsemanAccountFlow) {
    horsemanAccountFlowDAO.updateById(horsemanAccountFlow);
  }

  @Override
  public void deleteById(Integer id) {
    horsemanAccountFlowDAO.deleteById(id);
  }

  @Override
  public List<HorsemanAccountFlow> findByHorsemanId(Integer id) {
    final List<HorsemanAccountFlow> list = this.lambdaQuery()
        .eq(HorsemanAccountFlow::getHorsemanId, id).list();
    return list;
  }

  @Autowired
  public void setHorsemanAccountFlowDAO(HorsemanAccountFlowDAO horsemanAccountFlowDAO) {
    this.horsemanAccountFlowDAO = horsemanAccountFlowDAO;
  }
}